/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author ariel
 */
@Entity
@Table(name="payments_cuts")
public class PaymentsCut implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private Date datePay;
    private Float amount;
    private Employee employee;
    private List<AsignationCutPay> asignationCutPays;
    private BalanceEmployee balanceEmployee;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_payments_cut", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "date_pay")
    @Temporal(value = javax.persistence.TemporalType.DATE)
    public Date getDatePay() {
        return datePay;
    }

    public void setDatePay(Date datePay) {
        this.datePay = datePay;
    }

    public Float getAmount() {
        return amount;
    }

    public void setAmount(Float amount) {
        this.amount = amount;
    }

    @JoinColumn(name = "id_employee", referencedColumnName = "id_user")
    @ManyToOne(optional = false)
    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    @OneToMany(cascade=CascadeType.REMOVE, mappedBy="paymentsCut")
    public List<AsignationCutPay> getAsignationCutPays() {
        return asignationCutPays;
    }

    public void setAsignationCutPays(List<AsignationCutPay> asignationCutPays) {
        this.asignationCutPays = asignationCutPays;
    }

    @OneToOne(cascade=CascadeType.REMOVE, mappedBy = "paymentsCut")
    public BalanceEmployee getBalanceEmployee() {
        return balanceEmployee;
    }

    public void setBalanceEmployee(BalanceEmployee balanceEmployee) {
        this.balanceEmployee = balanceEmployee;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PaymentsCut)) {
            return false;
        }
        PaymentsCut other = (PaymentsCut) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.click.app.model.PaymentsCut[id=" + id + "]";
    }

}
